﻿#region Using namespaces

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;

#endregion

namespace BOL.Apps.GeneNetworkBrowser.Controls
{
    public class VertexShapeDataTemplateSelector : DataTemplateSelector
    {
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            try
            {
                ShapeType shapeType = (ShapeType)item;
                var mw = Application.Current.MainWindow;

                switch (shapeType)
                {
                    default:
                    case ShapeType.Circle:
                        return mw.FindResource("VertexCircleTemplate") as DataTemplate;
                    case ShapeType.Ellipse:
                        return mw.FindResource("VertexEllipseTemplate") as DataTemplate;
                    case ShapeType.Triangle:
                        return mw.FindResource("VertexTriangleTemplate") as DataTemplate;
                    case ShapeType.Rectangle:
                        return mw.FindResource("VertexRectangleTemplate") as DataTemplate;
                    case ShapeType.Square:
                        return mw.FindResource("VertexSquareTemplate") as DataTemplate;
                    case ShapeType.Pentagon:
                        return mw.FindResource("VertexPentagonTemplate") as DataTemplate;
                    case ShapeType.Hexagon:
                        return mw.FindResource("VertexHexagonTemplate") as DataTemplate;
                    case ShapeType.Heptagon:
                        return mw.FindResource("VertexHeptagonTemplate") as DataTemplate;
                    case ShapeType.Octagon:
                        return mw.FindResource("VertexOctagonTemplate") as DataTemplate;
                }
            }
            catch
            {
                return null;
            }
        }
    }
}
